package upload;
import org.apache.commons.fileupload.disk.DiskFileItem;

import java.io.File;
import java.io.OutputStream;
import java.io.IOException;

/**
 * 
 * @author CSDN
 *
 */
public class MyDiskFileItem extends DiskFileItem {

	private MyOutputStream out = null;
	private OutputStreamListener listener;

	public MyDiskFileItem(String fieldName, String contentType,
			boolean isFormField, String fileName, int sizeThreshold,
			File repository, OutputStreamListener listener) {
		super(fieldName, contentType, isFormField, fileName, sizeThreshold,
				repository);
		this.listener = listener;
	}
	
	@Override
	protected File getTempFile() {
		return super.getTempFile();
	}

	@Override
	public OutputStream getOutputStream() throws IOException {
		if (out == null) {
			out = new MyOutputStream(super.getOutputStream(), listener);
		}
		return out;
	}

}
